﻿using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleAppEfCore
{
    public class EfTestDbContext : DbContext
    {
        private static readonly string connectionString = @"Server=.\sqlexpress;Integrated Security=true;Initial Catalog=EfTestDb;";

        public EfTestDbContext() : this(new DbContextOptionsBuilder<EfTestDbContext>()
                   .UseSqlServer(new SqlConnection(connectionString))
                   .Options)
        {

        }
        public EfTestDbContext(DbContextOptions<EfTestDbContext> options) : base(options)
        {
        }
        public DbSet<Person> Persons { get; set; }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
            builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
        }
    }
}
